from django.db import models


# Create your models here.
class UserInfo(models.Model):
    """用户注册"""
    username = models.CharField(verbose_name='用户名', max_length=32)
    email = models.EmailField(verbose_name='邮箱')
    mobile_phone = models.CharField(verbose_name='手机号', max_length=64)
    password = models.CharField(verbose_name='密码', max_length=64)


class PriceStrategy(models.Model):
    """价格策略"""
    title = models.CharField(verbose_name='标题', max_length=32)
    price = models.IntegerField(verbose_name='价格')
    project_num = models.IntegerField(verbose_name='创建项目个数')
    project_member = models.CharField(verbose_name='每个项目成员个数',max_length=32)
    project_space = models.CharField(verbose_name='每个项目空间', max_length=32)
    one_project_space = models.CharField(verbose_name='单个项目的空间', max_length=32)
    create_time = models.DateField(verbose_name='创建时间', auto_now_add=True)


class Trade(models.Model):
    """交易表"""
    status_choice = (
        ('1', '未支付'),
        ('2', '已支付')
    )
    status = models.CharField(verbose_name='状态', choices=status_choice, default=1, max_length=32)
    user_id = models.ForeignKey(verbose_name='用户id', to='UserInfo', to_field='id', on_delete=models.CASCADE)
    price = models.ForeignKey(verbose_name='价格', to='PriceStrategy', to_field='id', on_delete=models.CASCADE)
    true_price = models.CharField(verbose_name='实际支付价格', max_length=32)
    start_time = models.DateField(verbose_name='开始时间', auto_now_add=True)
    end_time = models.DateField(verbose_name='结束时间')
    num_years = models.CharField(verbose_name='数量', max_length=32)
    trade_id = models.CharField(verbose_name='订单号', max_length=32)


class Project(models.Model):
    """项目表"""
    pro_name = models.CharField(verbose_name='项目名称', max_length=32)
    desc = models.CharField(verbose_name='项目描述', max_length=128)
    color_choice = (
        ('1', '#dddd'),
        ('2', '#uuu7'),
        ('3', '#uu97'),
        ('4', '#FFFF'),
        ('5', '#bbbb')
    )
    color = models.CharField(verbose_name='颜色', choices=color_choice, default=1, max_length=32)
    star_choice = (
        ('1', 'true'),
        ('2', 'false')
    )
    star = models.CharField(verbose_name='星标', choices=star_choice, default=2, max_length=32)
    part_num = models.IntegerField(verbose_name='参与人数')
    create_member = models.ForeignKey(verbose_name='创建者', to=UserInfo, to_field='id', on_delete=models.CASCADE)
    space_used = models.CharField(verbose_name='已使用空间', max_length=32)


class ProjectPart(models.Model):
    """项目参与者"""
    pro = models.ForeignKey(verbose_name='项目', to=Project, to_field='id', on_delete=models.CASCADE)
    user = models.ForeignKey(verbose_name='用户', to=UserInfo, to_field='id', on_delete=models.CASCADE)
    star_choice = (
        ('1', 'true'),
        ('2', 'false')
    )
    star = models.CharField(verbose_name='星标', choices=star_choice, default=2, max_length=32)
